﻿@model PagedList.IPagedList<CultuRAM.Models.Session>

@if (Model != null && Model.Count() != 0){
 
    <table id="tableSess" class="table table-hover table-striped table-bordered" style="width:100%;">
        <tr>
            <th style="width: 30%;">
                @Html.DisplayNameFor(model => model.FirstOrDefault().Title)
            </th>
            <th style="width: 10%;">
                @Html.DisplayNameFor(model => model.FirstOrDefault().Date)
            </th>
            <th style="width: 60%;">
                @Html.DisplayNameFor(model => model.FirstOrDefault().Place.NamePlace)
            </th>
        </tr>
        @foreach (var item in Model)
        {
            <tr id="@item.SessionId">
                <td>
                    @Html.DisplayFor(modelItem => item.Title)
                </td>
                <td style="text-align: center;">
                    @Html.DisplayFor(modelItem => item.Date)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Place.NamePlace)
                </td>
            </tr>
        }
    </table>
    
    <div class="row-fluid pagination-botton"> 
        <div class="span6">      
            
            @Html.Raw(@Ajax.ActionLink("replacetxt", "CreatePv", "Session",new { page = Model.PageNumber, idEvent = Model.FirstOrDefault().Event.EventId},
                             new AjaxOptions
                                 {
                                     UpdateTargetId="tabEventSesRight", 
                                     InsertionMode = InsertionMode.Replace, 
                                     HttpMethod = "GET", 
                                     OnComplete = "SesBgColorAdd()"
                                 }, new { @class = "btn btn-success btn-xs", id="btnAddSes" }) 
		            .ToHtmlString().Replace("replacetxt", "<i class=\"icon-plus icon-white\"></i> Adicionar"))

            @Html.Raw(@Ajax.ActionLink("replacetxt", "EditPv", "Session", new { page = Model.PageNumber},
                             new AjaxOptions
                                 {
                                     UpdateTargetId="tabEventSesRight", 
                                     InsertionMode = InsertionMode.Replace, 
                                     HttpMethod = "GET",
                                     OnComplete = "SesBgColorEdit()" 
                                 }, new { @class = "btn btn-warning btn-xs", id="btnEditSes" })  
		            .ToHtmlString().Replace("replacetxt", "<i class=\"icon-pencil icon-white\"></i> Editar"))
           
            @Html.Raw(@Ajax.ActionLink("replacetxt", "DeletePv", "Session", new { page = Model.PageNumber},
                             new AjaxOptions
                                 {
                                     UpdateTargetId = "tabEventSesRight",
                                     InsertionMode = InsertionMode.Replace,
                                     HttpMethod = "GET",
                                     OnComplete = "SesBgColorDel()"
                                 }, new { @class = "btn btn-danger btn-xs", id = "btnDelSes" })  
		            .ToHtmlString().Replace("replacetxt", "<i class=\"icon-remove icon-white\"></i> Eliminar"))
        </div> 
    
        <div class="span6">
            <div class="pagination" style="margin: 0">
                <ul>
                    @if (Model.HasPreviousPage)
                    {
                        <li>
                            @Ajax.ActionLink("«", "IndexPv", "Session", new { page = 1, idEvent = Model.FirstOrDefault().Event.EventId},
                                             new AjaxOptions
                                                 {
                                                     UpdateTargetId="tabEventSesLeft", 
                                                     InsertionMode = InsertionMode.Replace, 
                                                     HttpMethod = "GET" 
                                                 }, new { @class = ""}) 
                        </li> 
                        <li>
                            @Ajax.ActionLink("<", "IndexPv", "Session", new { page = Model.PageNumber - 1, idEvent = Model.FirstOrDefault().Event.EventId},
                                             new AjaxOptions
                                                 {
                                                     UpdateTargetId="tabEventSesLeft", 
                                                     InsertionMode = InsertionMode.Replace, 
                                                     HttpMethod = "GET" 
                                                 }, new { @class = ""}) 
                        </li>
                        <li class="">
                            <a href="#" data-original-title="" title="" class="">
                                Página <b> @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber)</b> de <b> @Model.PageCount </b>
                            </a>
                        </li>  
                    }
                    else
                    {
                        <li class="disabled"><a href="#" data-original-title="" title="" class="">«</a></li> 
                        <li class="disabled"><a href="#" data-original-title="" title="" class=""><</a></li> 
                        <li class="">
                            <a href="#" data-original-title="" title="" class="disabled">
                                Página <b> @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber)</b> de <b> @Model.PageCount </b>
                            </a>
                        </li> 
                    }
                    <li>
                    @if (Model.HasNextPage)
                    {
                        <li>
                            @Ajax.ActionLink(">", "IndexPv", "Session", new { page = Model.PageNumber + 1, idEvent = Model.FirstOrDefault().Event.EventId},
                                             new AjaxOptions
                                                 {
                                                     UpdateTargetId="tabEventSesLeft", 
                                                     InsertionMode = InsertionMode.Replace, 
                                                     HttpMethod = "GET" 
                                                 }, new { @class = ""}) 
                        </li>
                        <li>
                            @Ajax.ActionLink("»", "IndexPv", "Session", new { page = Model.PageCount, idEvent = Model.FirstOrDefault().Event.EventId},
                                             new AjaxOptions
                                                 {
                                                     UpdateTargetId="tabEventSesLeft", 
                                                     InsertionMode = InsertionMode.Replace, 
                                                     HttpMethod = "GET" 
                                                 }, new { @class = ""}) 
                        </li>
                    }
                    else
                    {
                        <li class="disabled"><a href="#" data-original-title="" title="" class="disabled">></a></li> 
                        <li class="disabled"><a href="#" data-original-title="" title="" class="disabled">»</a></li>
                    }
                </ul>
            </div>  
                  
        </div>
    </div>
    

}else{
    
    <div id="msgInf_" class="alert alert-warning" style="margin-top: 10px;">Este evento não tem Sessões definidas!</div>
    <br/>
    <p> @Html.Raw(@Ajax.ActionLink("replacetxt", "CreatePv", "Session",new { ViewBag.idEv },
                             new AjaxOptions
                                 {
                                     UpdateTargetId="tabEventSesRight", 
                                     InsertionMode = InsertionMode.Replace, 
                                     HttpMethod = "GET", 
                                     OnComplete = "SesBgColorAdd()"
                                 }, new { @class = "btn btn-success btn-xs", id="btnAddSes" }) 
		            .ToHtmlString().Replace("replacetxt", "<i class=\"icon-plus icon-white\"></i> Adicionar"))

    </p> 
}


@Scripts.Render("~/bundles/culturam")